
$("body").keydown(function() {
    if (event.keyCode == "13") {//keyCode=13是回车键
        Login();
    }
})

function Login(){
	
	/*	登录验证	*/
	$.ajax({
		type:'post',
		url: 'checkLogin',
		data:{
			  studentNumber:$("#userId").val(),
			  password:$("#password").val()
		},
		/*async:false,*/
		success:function(data){
			if(data.realname=="sorry"){
                alert("登陆失败");
			}
			else {
                var jsonData = JSON.stringify(data);
				setCookie("user",jsonData);
				/*	页面跳转：跳转至团队交流	*/
				if(data.role=="teacher"){
                    window.location.href="../course.html";
				}
                if(data.role=="student"){
                    window.location.href="../student.html";
                }
			}
		},
		error:function(){
			$("#failInfo").css("display","block");
			console.log("failed");
		}
	});
}